﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/ViewV5/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.css" rel="stylesheet">
    <link href="/ViewV5/CSS/BaseClass.css" rel="stylesheet" type="text/css" />
    <script src="/ViewV5/JS/jquery-1.11.2.min.js"></script>
    <script src="/ViewV5/JS/jquery-migrate-1.1.0.min.js"></script>
    <script src="/ViewV5/JS/avalon.js"></script>
    <script src="/ViewV5/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/ViewV5/JS/SZHLCommon.js?jsver=20160915"></script>
    <style>
        .pCard {
            min-width: 80px;
            text-align: center;
            margin: 0 5px 5px 5px;
        }
    </style>
    <script type="text/javascript">
        $.ajaxSetup({
            async: false
        });
        var rolecode = ComFunJS.getQueryString("rolecode");
        var model = avalon.define({
            $id: "RoleAdd",
            type: ComFunJS.getQueryString("type"),
            RoleUser: "",
            RoleData: { "RoleName": "", "RoleDec": "", "IsUse": "Y", "IsSysRole": "N", "roleType": "业务职务" },
            RoleEdit: function () {
          
                model.EditFun();

            }, EditFun: function () {
                if (!model.RoleData.RoleName) {
                    parent.ComFunJS.winwarning("请输入职务名称");
                    return;
                }
                var modelValue = JSON.stringify(model.RoleData.$model);
                $.post("/API/VIEWAPI.ashx", { Action: "XTGL_EditRole", P1: modelValue, P2: model.RoleUser },
                function (result) {
                    result = JSON.parse(result);
                    if ($.trim(result.ErrorMsg) != "") {
                        parent.ComFunJS.winwarning(result.ErrorMsg);
                    } else {
                        parent.ComFunJS.winsuccess("操作成功");
                        setTimeout("location.reload()", 1000);
                        var piframe = $("iframe", top.frames["main"].document)[0];
                        if (piframe) {
                            piframe.contentWindow.location.reload()
                        }
                    }
                });
            },
            SetFrameHeight: function (framename) {
                var oFrm = document.getElementById(framename);
                oFrm.onload = oFrm.onreadystatechange = function () {
                    if (this.readyState && this.readyState != 'complete') return;
                    else {
                        var mainheight = $("#dvContent").height() - 45;
                        $("#" + framename).height(mainheight);
                        $("#mastmenu").height(mainheight);
                        $(window.frames[framename].document).find(".maindiv").css({ height: mainheight + "px", overflow: "auto" });
                    }
                }
            }
        });
        avalon.ready(function () {
            if (rolecode) {
                //获取主要菜单
                $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETROLEBYCODE', { "P1": rolecode }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.RoleData = resultData.Result;
                        if (resultData.Result1)
                        {
                            $(resultData.Result1).each(function (i, item) {
                                model.RoleUser += item.UserName + ",";
                            })
                        }
                        model.RoleUser = model.RoleUser.substring(0, model.RoleUser.length - 1);
                    }
                })
            }
            ComFunJS.initForm();

        })

    </script>
</head>
<body ms-controller="RoleAdd">
    <div class="container-fluid maindiv" style="margin: 50px 20px 50px 20px">
        <div id="addForm" class="form-horizontal">
            <div class="form-group" ms-visible="!type">
                <label for="branchName" class="col-xs-3 control-label text-right">职务名称</label>
                <div class="col-xs-7">
                    <input type="text" class="form-control" ms-attr-disabled="rolecode!=''" ms-duplex="RoleData.RoleName" id="branchName" placeholder="请输入职务名称" />
                </div>
            </div>
            <div class="form-group" style="display:none">
                <label for="branchShort" class="col-xs-3 control-label text-right">职务类型</label>
                <div class="col-xs-7">
                    <select id="roleType" ms-attr-disabled="rolecode!=''" class="form-control" ms-duplex="RoleData.roleType">
                        <option value="职务职务" ms-attr-selected="RoleData.roleType=='职务职务'?'selected':''">职务职务</option>
                        <option value="业务职务" ms-attr-selected="RoleData.roleType=='业务职务'?'selected':''">业务职务</option>
                    </select>
                </div>
            </div>
            <div class="form-group hidden">
                <label for="branchShort" class="col-xs-3 control-label text-right">是否可用</label>
                <div class="col-xs-7">
                    <select id="isUse" class="form-control" ms-duplex="RoleData.IsUse">
                        <option value="Y">是</option>
                        <option value="N">否</option>
                    </select>
                </div>
            </div>
            <div class="form-group hide">
                <label for="branchShort" class="col-xs-3 control-label text-right ">是否系统职务</label>
                <div class="col-xs-7">
                    <select id="isUse" class="form-control" ms-duplex="RoleData.IsSysRole">
                        <option value="Y" ms-attr-selected="RoleData.IsSysRole=='Y'?'selected':''">是</option>
                        <option value="N" ms-attr-selected="RoleData.IsSysRole=='N'?'selected':''">否</option>
                    </select>
                </div>
            </div>
            <div class="form-group" ms-visible="!type">
                <label for="branchDesc" class="col-xs-3 control-label text-right">职务描述</label>
                <div class="col-xs-7">
                    <textarea class="form-control" ms-duplex="RoleData.RoleDec" id="branchDesc" placeholder="请输入职务描述"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">职务人员</label>
                <div class="col-xs-7">
                    <input type="text" value="" class="span2   form-control  szhl_getPeoples" ms-duplex="RoleUser" id="qygg2" />
                </div>
            </div>
            <div class="form-group  ">
                <div class="col-xs-12 text-center ">
                    <input type="button" id="btnAdd" value="保存" ms-click="RoleEdit()" class="btn btn-lg btn-success" />
                </div>
            </div>
        </div>
    </div>
</body>
</html>
